#ifndef BARRIER_HPP_
#define BARRIER_HPP_

#include <Bust/Utilities.hpp>

namespace bust {

class Barrier : public bust::noncopyable {
	public:
		/**
		 *  Constructor
		 */
		Barrier( int numThreads = 0 );
		/**
		 *  Destructor
		 */
		virtual ~Barrier();
		/**
		 *  Reset the barrier to it's original state.
		 */
		virtual void reset();
		/**
		 *  Block until numThreads threads have entered the barrier.
		 */
		virtual void block( unsigned int numThreads = 0 );
		/**
		 * Return number of curently blocked threads
		 * @return
		 */
		virtual int currentlyBlocked() {
			return blockedNum;
		}
	private:
		Barrier( const Barrier &b ) {
		}
		Barrier &operator=( const Barrier &b ) {
			return * ( this );
		}
		int blockedNum;
		void *_data;
};

}

#endif /* BARRIER_HPP_ */
